package edu.pku.sei.modeler.uml.actions;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;

import edu.pku.sei.modeler.model.structure.MetaDiagram;

public class RenameDiagramAction extends Action {
	private Object obj;
	public RenameDiagramAction(){
		super();
		this.setText("rename");
		this.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
				getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
	}
	public void setTreeObj(Object obj) {
		this.obj = obj;
	}
	public void run(){
		if (obj instanceof MetaDiagram){
			InputDialog dialog = new InputDialog(null, "",
					"Input new Name:", ((MetaDiagram)obj).getName(), null);
			if (dialog.open() == InputDialog.OK) {
				((MetaDiagram)obj).setName(dialog.getValue());
			}
		}
	}
}
